﻿using Domain.Entities;
using JFnetcore.Models.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JFnetcore.CS
{
    public class vUserHelp
    {
        public List<vUser> GetVUserList(List<User> productlist, List<Role> producttypelist)
        {
            var vlist = from a in productlist
                        join b in producttypelist
                        on a.Role_id equals b.Id
                        where a.Disable != 0
                        select new
                        {
                            User_Id = a.Id,
                            Login_name = a.Login_name,
                            User_name = a.User_name,
                            User_email = a.User_email,
                            Createtime = a.Createtime,
                            Disable = a.Disable,
                            Role_name = b.Role_name,
                            Role_Id = b.Id

                        };
            return vlist.ToList().Select(C => new vUser
            {
                User_id = C.User_Id,
                Login_name = C.Login_name,
                User_name = C.User_name,
                User_email = C.User_email,
                Createtime = C.Createtime,
                Disable = C.Disable,
                Role_name = C.Role_name,
                Role_id = C.Role_Id
            }).ToList();
        }
    }
}
